home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / volume1a / readme.txt < prev   
Text File  |  1998-01-05  |  17KB  |  412 lines

  1.              --------------------------------------------
  2.              Microsoft Volume Sample Project Readme File
  3.                             January l998
  4.              -------------------------------------------
  5.                     (c) Microsoft Corporation, 1997
  6.  
  7.  
  8. VOLUME.EXE is a self-extracting compressed file that contains a sample
  9. project demonstrating how to set the volume and microphone levels using
  10. Visual Basic.
  11.  
  12. After downloading and running the self-extracting file, the following files
  13. are copied to the Volume Level Project directory on your hard drive:
  14.  
  15.   Form1.frm    - the main form in the project
  16.   Module1.bas  - the module containing the function and type declarations.
  17.   Project1.vbp - the project file
  18.   Project1.vbw - the project workspace file
  19.   Readme.txt   - you are currently reading this file.
  20.  
  21. To set these microphone and volume levels from Visual Basic, use the
  22. following Windows API functions:
  23.  
  24.  - GlobalAlloc - allocates the specified number of bytes from the heap.
  25.  
  26.  - GlobalLock - locks a global memory object and returns a pointer to the
  27.    first byte of the object[ASCII 146]s memory block. The memory block
  28.    associated with a locked memory object cannot be moved or discarded.
  29.  
  30.  - GlobalFree - frees the specified global memory object and invalidates
  31.    its handle.
  32.  
  33.  - mixerClose - closes the specified mixer device.
  34.  
  35.  - mixerGetControlDetails - retrieves details about a single control
  36.    associated with an audio line.
  37.  
  38.  - mixerGetDevCaps - queries a specified mixer device to determine its
  39.    capabilities.
  40.  
  41.  - mixerGetID - retrieves the device identifier for a mixer device
  42.    associated with a specified device handle.
  43.  
  44.  - mixerGetLineControls - retrieves one or more controls associated with an
  45.    audio line.
  46.  
  47.  - mixerGetLineInfo - retrieves information about a specific line of a
  48.    mixer device.
  49.  
  50.  - mixerGetNumDevs - retrieves the number of mixer devices present in the
  51.    system.
  52.  
  53.  - mixerMessage - sends a custom mixer driver message directly to a mixer
  54.    driver.
  55.  
  56.  - mixerOpen - opens a specified mixer device and ensures that the device
  57.    will not be removed until the application closes the handle.
  58.  
  59.  - mixerSetControlDetails - sets properties of a single control associated
  60.    with an audio line.
  61.  
  62. The next section shows how to create a sample project that uses these
  63. functions to set the volume and microphone levels.
  64.  
  65. Create the Sample Project
  66. -------------------------
  67.  
  68. 1. Start a new Standard EXE project in Visual Basic. Form1 is created by
  69.    default.
  70.  
  71. 2. Add two command buttons, two text boxes, and two labels to Form1.
  72.  
  73. 3. Add a Module to the project by completing the following steps:
  74.  
  75.     - From the Project menu, click Add module. The Add Module dialog box
  76.       appears.
  77.  
  78.     - From the New tab, choose Module and click OK. A new module is added
  79.       to your project.
  80.  
  81. 4. Copy the following code to the Code window of Module1:
  82.  
  83.       Option Explicit
  84.  
  85.       Public Const MMSYSERR_NOERROR = 0
  86.       Public Const MAXPNAMELEN = 32
  87.       Public Const MIXER_LONG_NAME_CHARS = 64
  88.       Public Const MIXER_SHORT_NAME_CHARS = 16
  89.       Public Const MIXER_GETLINEINFOF_COMPONENTTYPE = &H3&
  90.       Public Const MIXER_GETCONTROLDETAILSF_VALUE = &H0&
  91.       Public Const MIXER_GETLINECONTROLSF_ONEBYTYPE = &H2&
  92.       Public Const MIXERLINE_COMPONENTTYPE_DST_FIRST = &H0&
  93.       Public Const MIXERLINE_COMPONENTTYPE_SRC_FIRST = &H1000&
  94.  
  95.       Public Const MIXERLINE_COMPONENTTYPE_DST_SPEAKERS = _
  96.                      (MIXERLINE_COMPONENTTYPE_DST_FIRST + 4)
  97.  
  98.       Public Const MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE = _
  99.                      (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3)
  100.  
  101.       Public Const MIXERLINE_COMPONENTTYPE_SRC_LINE = _
  102.                      (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2)
  103.  
  104.       Public Const MIXERCONTROL_CT_CLASS_FADER = &H50000000
  105.       Public Const MIXERCONTROL_CT_UNITS_UNSIGNED = &H30000
  106.  
  107.       Public Const MIXERCONTROL_CONTROLTYPE_FADER = _
  108.                      (MIXERCONTROL_CT_CLASS_FADER Or _
  109.                      MIXERCONTROL_CT_UNITS_UNSIGNED)
  110.  
  111.       Public Const MIXERCONTROL_CONTROLTYPE_VOLUME = _
  112.                      (MIXERCONTROL_CONTROLTYPE_FADER + 1)
  113.  
  114.       Declare Function mixerClose Lib "winmm.dll" _
  115.                      (ByVal hmx As Long) As Long
  116.  
  117.       Declare Function mixerGetControlDetails Lib "winmm.dll" _
  118.                      Alias "mixerGetControlDetailsA" _
  119.                      (ByVal hmxobj As Long, _
  120.                      pmxcd As MIXERCONTROLDETAILS, _
  121.                      ByVal fdwDetails As Long) As Long
  122.  
  123.       Declare Function mixerGetDevCaps Lib "winmm.dll" _
  124.                      Alias "mixerGetDevCapsA" _
  125.                      (ByVal uMxId As Long, _
  126.                      ByVal pmxcaps As MIXERCAPS, _
  127.                      ByVal cbmxcaps As Long) As Long
  128.  
  129.       Declare Function mixerGetID Lib "winmm.dll" _
  130.                      (ByVal hmxobj As Long, _
  131.                      pumxID As Long, _
  132.                      ByVal fdwId As Long) As Long
  133.  
  134.       Declare Function mixerGetLineControls Lib "winmm.dll" _
  135.                      Alias "mixerGetLineControlsA" _
  136.                      (ByVal hmxobj As Long, _
  137.                      pmxlc As MIXERLINECONTROLS, _
  138.                      ByVal fdwControls As Long) As Long
  139.  
  140.       Declare Function mixerGetLineInfo Lib "winmm.dll" _
  141.                      Alias "mixerGetLineInfoA" _
  142.                      (ByVal hmxobj As Long, _
  143.                      pmxl As MIXERLINE, _
  144.                      ByVal fdwInfo As Long) As Long
  145.  
  146.       Declare Function mixerGetNumDevs Lib "winmm.dll" () As Long
  147.  
  148.       Declare Function mixerMessage Lib "winmm.dll" _
  149.                      (ByVal hmx As Long, _
  150.                      ByVal uMsg As Long, _
  151.                      ByVal dwParam1 As Long, _
  152.                      ByVal dwParam2 As Long) As Long
  153.  
  154.       Declare Function mixerOpen Lib "winmm.dll" _
  155.                      (phmx As Long, _
  156.                      ByVal uMxId As Long, _
  157.                      ByVal dwCallback As Long, _
  158.                      ByVal dwInstance As Long, _
  159.                      ByVal fdwOpen As Long) As Long
  160.  
  161.       Declare Function mixerSetControlDetails Lib "winmm.dll" _
  162.                      (ByVal hmxobj As Long, _
  163.                      pmxcd As MIXERCONTROLDETAILS, _
  164.                      ByVal fdwDetails As Long) As Long
  165.  
  166.       Declare Sub CopyStructFromPtr Lib "kernel32" _
  167.                      Alias "RtlMoveMemory" _
  168.                      (struct As Any, _
  169.                      ByVal ptr As Long, _
  170.                      ByVal cb As Long)
  171.  
  172.       Declare Sub CopyPtrFromStruct Lib "kernel32" _
  173.                      Alias "RtlMoveMemory" _
  174.                      (ByVal ptr As Long, _
  175.                      struct As Any, _
  176.                      ByVal cb As Long)
  177.  
  178.       Declare Function GlobalAlloc Lib "kernel32" _
  179.                      (ByVal wFlags As Long, _
  180.                      ByVal dwBytes As Long) As Long
  181.  
  182.       Declare Function GlobalLock Lib "kernel32" _
  183.                      (ByVal hmem As Long) As Long
  184.  
  185.       Declare Function GlobalFree Lib "kernel32" _
  186.                      (ByVal hmem As Long) As Long
  187.  
  188.       Type MIXERCAPS
  189.          wMid As Integer                   '  manufacturer id
  190.          wPid As Integer                   '  product id
  191.          vDriverVersion As Long            '  version of the driver
  192.          szPname As String * MAXPNAMELEN   '  product name
  193.          fdwSupport As Long                '  misc. support bits
  194.          cDestinations As Long             '  count of destinations
  195.       End Type
  196.  
  197.       Type MIXERCONTROL
  198.          cbStruct As Long           '  size in Byte of MIXERCONTROL
  199.          dwControlID As Long        '  unique control id for mixer device
  200.          dwControlType As Long      '  MIXERCONTROL_CONTROLTYPE_xxx
  201.          fdwControl As Long         '  MIXERCONTROL_CONTROLF_xxx
  202.          cMultipleItems As Long     '  if MIXERCONTROL_CONTROLF_MULTIPLE
  203.                                     '  set
  204.          szShortName As String * MIXER_SHORT_NAME_CHARS  ' shor